﻿using Microsoft.EntityFrameworkCore;
using SMARTHOTEL.hotel;
using SMARTHOTEL.Products;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.Identity;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement;

namespace SMARTHOTEL.EntityFrameworkCore;


[ConnectionStringName("Default")]
public class SMARTHOTELDbContext :
    AbpDbContext<SMARTHOTELDbContext>

{
    /* Add DbSet properties for your Aggregate Roots / Entities here. */

    #region Entities from the modules

    /* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext
     * and replaced them for this DbContext. This allows you to perform JOIN
     * queries for the entities of these modules over the repositories easily. You
     * typically don't need that for other modules. But, if you need, you can
     * implement the DbContext interface of the needed module and use ReplaceDbContext
     * attribute just like IIdentityDbContext and ITenantManagementDbContext.
     *
     * More info: Replacing a DbContext of a module ensures that the related module
     * uses this DbContext on runtime. Otherwise, it will use its own DbContext class.
     */

   
    #endregion
    public DbSet<RoomType> RoomTypes { get; set; }
    public DbSet<ProductLabel> productLabels { get; set; }
    public SMARTHOTELDbContext(DbContextOptions<SMARTHOTELDbContext> options)
        : base(options)
    {

    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);

        /* Include modules to your migration db context */

   
        builder.ConfigureSettingManagement();
        builder.ConfigureBackgroundJobs();
        builder.ConfigureAuditLogging();


        /* Configure your own tables/entities inside here */

        builder.Entity<RoomType>(b =>
        {
            b.ToTable(SMARTHOTELConsts.DbTablePrefix + nameof(RoomType), SMARTHOTELConsts.DbSchema);
            b.ConfigureByConvention();
        });
    }
}
